<template>
  <div>
     <van-nav-bar
        title="垃圾清运数量上报"
        left-text=""
        :left-arrow="false"
        :fixed="false"
      />
      <!-- <div class="title"></div> -->
      <van-cell-group>
        <van-field v-model="name" label="上报人姓名：" placeholder="请输入姓名" />
      </van-cell-group>
      <van-cell-group>
        <van-field v-model="garbageCarCode" label="垃圾车编号：" placeholder="请输入编号" />
      </van-cell-group>
      <van-cell-group>
        <van-field v-model="count" label="今日收运量：" placeholder="请输入收运量" />
      </van-cell-group>

      <div class="goindex">
      <van-button
        class="goindex-back"
        round
        type="info"
        color="linear-gradient(90deg, #00C4C6 0%, #01DC8E 100%)"
        block
        @click="goindexhandleBack"
        >返回首页</van-button
      >
      <van-button
        class="goindex-back"
        round
        color="linear-gradient(270deg, #FF8F43 0%, #F67665 100%)"
        type="primary"
        block
        @click="goindexhandleGo"
        >提交</van-button
      >
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant'
import { garbageInsert } from '../../../utils/api'
export default {
  name: "trashPickupMain",
  data() {
    return{
      name:'',
      garbageCarCode:'',
      count:''
    }
  },
  mounted () {
     //初始数据获取
  },
  methods: {
    goindexhandleGo(){
      let param = {
        name: this.name,
        garbageCarCode: this.garbageCarCode,
        count: this.count
      }
      garbageInsert(param).then(res=>{
        if(res.code === 200){
          Toast.success(res.message)
        }else{
          Toast.fail(res.message)
        }
        this.$router.push({ path: "/trashPickupMain/trashPickupCase" });
      })
    },
    goindexhandleBack() {
      this.$router.push({ path: "/" });
    }
  }
}
</script>

<style scoped>
.title {
  width: 150px;
  height: 50px;
}
.goindex {
  width: 90%;
  margin: 30px auto;
  display: flex;
  justify-content: space-between;
}
.goindex-back{
  width: 40%;
}
</style>
